using System;
using System.IO.Packaging;
using System.Workflow.ComponentModel;

namespace OWA.Activities
{
	public class ValidateSignaturesActivity
        : AbstractPackageActivity
	{
        protected override ActivityExecutionStatus Execute(
            ActivityExecutionContext executionContext)
        {
            Package package = GetPackage();
            PackageDigitalSignatureManager mgr = new PackageDigitalSignatureManager(package);
            if (mgr.IsSigned)
            {
                throw new SignatureVerificationException(
                    VerifyResult.NotSigned);
            }
            VerifyResult result = mgr.VerifySignatures(false);
            if (result != VerifyResult.Success)
            {
                throw new SignatureVerificationException(result);
            }        
            return ActivityExecutionStatus.Closed;
        }
	}
}
